<script setup>
defineProps({
  list: {
    type: Array,
    default: () => []
  },
  active: {
    type: String,
    default: 'all'
  }
})
const emits = defineEmits(['setActive', 'clearCompleted'])
const setActiveFn = str => {
  emits('setActive', str)
}
</script>

<template>
  <footer class="footer">
    <span class="todo-count"
      ><strong>{{ list.length }}</strong> item left</span
    >
    <ul class="filters">
      <li>
        <a
          @click="setActiveFn('all')"
          :class="{ selected: active === 'all' }"
          href="#/"
          >All</a
        >
      </li>
      <li>
        <a
          @click="setActiveFn('active')"
          :class="{ selected: active === 'active' }"
          href="#/active"
          >Active</a
        >
      </li>
      <li>
        <a
          @click="setActiveFn('completed')"
          :class="{ selected: active === 'completed' }"
          href="#/completed"
          >Completed</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="emits('clearCompleted')">
      Clear completed
    </button>
  </footer>
</template>

<style lang="less" scoped></style>
